#ifndef LIB_TWCORE_INTERNAL_CONTEXTMODEL_H_
#define LIB_TWCORE_INTERNAL_CONTEXTMODEL_H_

#include "IContext.h"
#include <QAbstractItemModel>
#include <QList>

namespace TWCore
{
	class ContextModel : public QAbstractItemModel
	{
		Q_OBJECT
		Q_DISABLE_COPY(ContextModel)
		public:
			explicit ContextModel(QObject* parent=0);
			~ContextModel(){}

			int rowCount(const QModelIndex &parent) const;
			int columnCount(const QModelIndex &) const{return 2;}
			QVariant data(const QModelIndex &index, int role) const;
			QVariant headerData(int section, Qt::Orientation orientation,
								int role = Qt::DisplayRole) const;

			QModelIndex index(int row, int column,
							  const QModelIndex& parent = QModelIndex()) const{Q_UNUSED(parent) return createIndex(row,column,0);}
			QModelIndex parent(const QModelIndex &) const{return QModelIndex();}

			void setData(QList<IContext*>* cs){this->contexts = cs;}
			void appendData(IContext* c);
			void removeData(int index);
			void moveData(int sourceIndex,int destIndex);

			bool isItemConfigurable(const QModelIndex&,int index=-1) const;
		private:
			QList<IContext*>* contexts;
	};
}

#endif /* LIB_TWCORE_INTERNAL_CONTEXTMODEL_H_ */
